
public class Sorter {
	public void quickSort(int a[], int low, int high){
		int pivot;
		int scanup, scandown, mid;
		if(high-low<=0){
			return;
		}else{
			if(high-low==1){
				if(a[high]<a[low]){
					int temp = a[low];
					a[low] = a[high];
					a[high] = temp;
				}
				return;
			}
			mid=(low+high)/2;
			pivot = a[mid];
			int temp = a[mid];
			a[mid] = a[low];
			a[low] = temp;
			scanup = low+1;
			scandown = high;
			do{
				while(scanup<=scandown&&a[scanup]<=pivot){
					scanup++;
				}
				while(pivot<a[scandown]){
					scandown--;
				}
				if(scanup<scandown){
					int temp1 = a[scanup];
					a[scanup] = a[scandown];
					a[scandown] = temp1;
				}
			}while(scanup<scandown);
			
			a[low] = a[scandown];
			a[scandown] = pivot;
			
			if(low<scandown-1){
				quickSort(a, low, scandown-1);
			}
			if(scandown+1<high){
				quickSort(a, scandown+1, high);
			}
		}
		
	}
}
